package carnet;

public class ToText implements Visitor{
	private String text;
	
	public ToText(){
		text = new String();
	}
	
	@Override
	public void visitCarnet(Carnet c){
		text += "Carnet "+ c.type +"\n";
		for(Contact ct : c.getContacts()){
			ct.accept(this);
			text += "\n";
		}
	}

	@Override
	public void visitContact(Contact c) {
		text += c.getNom().getValeur() +" ; ";
		text += c.getPrenom().getValeur() +" ; ";
		text += c.getAdresse().getValeur() +" ; ";
		text += c.getTelephone().getValeur() +" ; ";
		for(Champ ch : c.getAutresChamps()){
			ch.accept(this);
		}
	}
	
	
	@Override
	public void visitChamp(Champ c) {
		text += c.getValeur() + " ; ";
	}
	

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

}
